require(rgdal)
require(ggplot2)
library(devtools)
library(sf)
library(tidyverse)
library(readxl)
library(sf)
library(fs)
library(magrittr)
library(leaflet)
library(leaflet.extras)
library(readr)
#Animal data
animal_data <- read_csv('dangerous_species.csv')
animal_df_all <- data.frame(animal_data)
animal_df <-animal_df_all[animal_df_all[, "Common_Name"] == "Bull Ant",]
#unzip(zipfile = "SDM843965.zip",
# exdir = 'PARKRES')
#parkres_shp <- readOGR(dsn = "PARKRES/ll_gda94/sde_shape/whole/VIC/CROWNLAND/layer", layer = "parkres")
parkres_shp <- readOGR(dsn = "layer", layer = "parkres")
# keeping only national parks
national_shp = subset(parkres_shp, str_detect(NAME, "National"))
anglerIcon1 <- makeIcon(
iconUrl = "https://www.flaticon.com/svg/vstatic/svg/4433/4433047.svg?token=exp=1617229155~hmac=c5d16a1f20784de52d4d096619d2a681",
iconWidth = 12, iconHeight = 12,
iconAnchorX = 22, iconAnchorY = 94,
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
anglerIcon2 <- makeIcon(
iconUrl = "ant.png",
iconWidth = 10, iconHeight = 10,
iconAnchorX = 22, iconAnchorY = 94,
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
pal <- colorFactor(
palette = palette(rainbow(63)),
domain = national_shp$NAME
)
leaflet() %>%
addProviderTiles("Stamen.Terrain") %>%
setView(144.2794, -36.7570, zoom = 7) %>%
addPolygons(data = national_shp,color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~pal(NAME),
highlightOptions = highlightOptions(color = "#888", weight = 2,
bringToFront = TRUE),
label = national_shp$NAME,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto"))%>%
addMarkers(data = animal_df,~decimalLongitude,~decimalLatitude, label = ~Common_Name,icon = anglerIcon2,
#popup = paste("<b>Hospital name:</b>", hospital$Name, "<br>",
# "<b>Hospital address:</b>", hospital$Address),
# clusterOptions = markerClusterOptions(),
labelOptions = labelOptions(noHide = FALSE, direction = "left",textsize='8px',
style=list(
'color'= "black",
'font-family'= 'serif',
'font-style'= 'italic',
'box-shadow' = '3px 3px rgba(0,0,0,0.25)',
'font-size' = '15px',
'border-color' = 'rgba(0,0,0,0.5)'
))
)